*TABLE 1
*Childcare

clear
foreach t of numlist 1 2 3 4 5 6 7 8 9 10 {
use synth`t'_615.dta, clear
drop _Co_Number _W_Weight
gen pre = 1 if _time<1996
keep if pre==1
gen spe  = (_Y_treated - _Y_synthetic)^2
egen m_y_treted = mean(_Y_treated )
gen sqdmean = (_Y_treated - m_y_treted)^2
egen numerator = sum(spe)
egen denominator = sum(sqdmean)
gen rsq = 1- (numerator/denominator)
*Table 1: Childcare pre-r2: Means in the following output
su rsq
}

clear
use "childcareoutput.dta"

foreach t of numlist 1 2 3 4 5 6 7 8 9 10{
sort komnr model
qui su RMSPE if komnr==615 & model==`t'
gen RMSPE_Fla_`t' = r(mean)
egen rank_RMSPE_`t' = rank(-RMSPE) if model==`t'
gen rank_RMSPE_Fla_`t'=rank_RMSPE_`t' if komnr==615 & model==`t'
gen p_Fla_`t' = rank_RMSPE_Fla_`t'/164
}

*Table 1: Childcare Post MSPE column: Means in the following output
bys model: su postmspe if komnr!=615

*Table 1: Childcare p-value column: Means in the following output
su p_Fla_*


*Education

clear
foreach t of numlist 1 2 3 4 5 6 7 8 9 10 {
use synthed`t'_615.dta, clear
drop _Co_Number _W_Weight
gen pre = 1 if _time<1996
keep if pre==1
gen spe  = (_Y_treated - _Y_synthetic)^2
egen m_y_treted = mean(_Y_treated )
gen sqdmean = (_Y_treated - m_y_treted)^2
egen numerator = sum(spe)
egen denominator = sum(sqdmean)
gen rsq = 1- (numerator/denominator)
*Table 1: Education pre-r2: Means in the following output
su rsq
}

clear
use "educationoutput.dta"

foreach t of numlist 1 2 3 4 5 6 7 8 9 10{
sort komnr model
qui su RMSPE if komnr==615 & model==`t'
gen RMSPE_Fla_`t' = r(mean)
egen rank_RMSPE_`t' = rank(-RMSPE) if model==`t'
gen rank_RMSPE_Fla_`t'=rank_RMSPE_`t' if komnr==615 & model==`t'
gen p_Fla_`t' = rank_RMSPE_Fla_`t'/164
}

*Table 1: Education Post MSPE column: Means in the following output
bys model: su postmspe if komnr!=615

*Table 1: Education p-value column: Means in the following output
su p_Fla_*



*Elderlycare

clear
foreach t of numlist 1 2 3 4 5 6 7 8 9 10 {
use synthel`t'_615.dta, clear
drop _Co_Number _W_Weight
gen pre = 1 if _time<1996
keep if pre==1
gen spe  = (_Y_treated - _Y_synthetic)^2
egen m_y_treted = mean(_Y_treated )
gen sqdmean = (_Y_treated - m_y_treted)^2
egen numerator = sum(spe)
egen denominator = sum(sqdmean)
gen rsq = 1- (numerator/denominator)
*Table 1: Elderlycare pre-r2: Means in the following output
su rsq
}

clear
use "elderlyoutput.dta"

foreach t of numlist 1 2 3 4 5 6 7 8 9 10{
sort komnr model
qui su RMSPE if komnr==615 & model==`t'
gen RMSPE_Fla_`t' = r(mean)
egen rank_RMSPE_`t' = rank(-RMSPE) if model==`t'
gen rank_RMSPE_Fla_`t'=rank_RMSPE_`t' if komnr==615 & model==`t'
gen p_Fla_`t' = rank_RMSPE_Fla_`t'/164
}

*Table 1: Elderlycare Post MSPE column: Means in the following output
bys model: su postmspe if komnr!=615

*Table 1: Elderlycare p-value column: Means in the following output
su p_Fla_*



*Healthcare

clear
foreach t of numlist 1 2 3 4 5 6 7 8 9 10 {
use synthhe`t'_615.dta, clear
drop _Co_Number _W_Weight
gen pre = 1 if _time<1996
keep if pre==1
gen spe  = (_Y_treated - _Y_synthetic)^2
egen m_y_treted = mean(_Y_treated )
gen sqdmean = (_Y_treated - m_y_treted)^2
egen numerator = sum(spe)
egen denominator = sum(sqdmean)
gen rsq = 1- (numerator/denominator)
*Table 1: Healthcare pre-r2: Means in the following output
su rsq
}

clear
use "healthoutput.dta"

foreach t of numlist 1 2 3 4 5 6 7 8 9 10{
sort komnr model
qui su RMSPE if komnr==615 & model==`t'
gen RMSPE_Fla_`t' = r(mean)
egen rank_RMSPE_`t' = rank(-RMSPE) if model==`t'
gen rank_RMSPE_Fla_`t'=rank_RMSPE_`t' if komnr==615 & model==`t'
gen p_Fla_`t' = rank_RMSPE_Fla_`t'/164
}

*Table 1: Healthcare Post MSPE column: Means in the following output
bys model: su postmspe if komnr!=615

*Table 1: Healthcare p-value column: Means in the following output
su p_Fla_*
